//
//  ViewController.m
//  DEMO
//
//  Created by J on 16/2/20.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIImageView *sun;
@property (weak, nonatomic) IBOutlet UIImageView *student;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    UIImage* img= [UIImage imageNamed:@"520_userguid_bg"];
    UIScrollView* sc = [[UIScrollView alloc]initWithFrame:self.view.bounds];
    sc.contentSize = img.size;
    UIImageView* imgView= [[UIImageView alloc]initWithImage:img];
    CGRect ori = imgView.frame;
    ori.size.height = self.view.frame.size.height;
    imgView.frame = ori;
    [sc addSubview:imgView];
    [self.view insertSubview:sc atIndex:0];
    sc.decelerationRate = 0.1;//减速速率 越小 减速越快
    sc.delegate = self;
    
    
    
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    NSUInteger off = (int)scrollView.contentOffset.x%2+1;
    UIImage* img= [UIImage imageNamed:[NSString stringWithFormat:@"520_userguid_person_taitou_%d",off]];
    self.student .image = img;
    
    
    self.sun.transform = CGAffineTransformRotate(self.sun.transform, (3/180.0)*M_PI);
    
    
}


@end
